# Create your views here.

from django.http import HttpResponseRedirect,HttpResponse
from django.shortcuts import render
from contract import forms
from django.core.urlresolvers import reverse

def index(request):
    return HttpResponse('welcome to come the contract site')

def contact(request):
    if request.method == "POST":
        form = forms.ContactForm(request.POST)
        if form.is_valid():
            subject = form.cleaned_data['subject']
            message = form.cleaned_data['message']
            sender = form.cleaned_data['sender']
            cc_myself = form.cleaned_data['cc_myself']
            recipients = ['info@example.com']
            if cc_myself:
                recipients.append(sender)

            url = reverse('thanks')
            return HttpResponseRedirect(url)
            #return HttpResponseRedirect('/contact/thanks/')
    else:
        form = forms.ContactForm()
        return render(request,'contact1.html',{'form':form,})

def thanks(request):
    return HttpResponse('welcome to come the contract site and create a new contract')